package com.ethink.platform.controller.warehouse;

import cn.hutool.core.util.IdUtil;
import com.ethink.framework.common.constant.CommonRespCode;
import com.ethink.framework.common.db.KeyValueDTO;
import com.ethink.framework.common.exception.BusinessException;
import com.ethink.framework.common.web.BaseController;
import com.ethink.framework.common.web.context.SPRequestContextHolder;
import com.ethink.framework.common.web.response.CommonResponse;
import com.ethink.order.api.*;
import com.ethink.order.api.model.PurchaseOrderNoAndQtyModel;
import com.ethink.platform.controller.order.info.ExportInfo;
import com.ethink.platform.manager.ExportManager;
import com.ethink.report.api.info.TobSaleInfo;
import com.ethink.report.common.mapper.MateInventoryOrderQueryMapper;
import com.ethink.system.api.SystemFileFacade;
import com.ethink.system.api.info.SystemFileInfo;
import com.ethink.warehouse.api.LogisticsTraceApplyOrderFacade;
import com.ethink.warehouse.api.LogisticsTraceOrderFacade;
import com.ethink.warehouse.api.LogisticsTransferOrderFacade;
import com.ethink.warehouse.api.ReportMateInventoryAgeFacade;
import com.ethink.warehouse.api.enums.InventoryTypeEnum;
import com.ethink.warehouse.api.enums.SubjectEnum;
import com.ethink.warehouse.api.info.LogisticsStepInfo;
import com.ethink.warehouse.api.info.LogisticsTraceOrderInfo;
import com.ethink.warehouse.api.request.*;
import com.ethink.warehouse.api.response.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * 仓库库龄报表 Controller
 *
 * @author default
 * @date 2023-01-29
 */
@Tag(name = "ReportMateInventoryAgeController", description = "仓库库龄报表 Controller")
@RestController
@Slf4j
@RequestMapping("platform-server/v1/warehouse-service")
public class ReportMateInventoryAgeController extends BaseController {

    @Autowired
    private ReportMateInventoryAgeFacade reportMateInventoryAgeFacade;

    @Autowired
    private ExportManager exportManager;

    @Operation(summary = "分页查询")
    @GetMapping("/ReportMateInventoryAge/query")
    public CommonResponse<List<ReportMateInventoryAgeQueryResponse>> queryReportMateInventoryAge(ReportMateInventoryAgeQueryRequest request) {
        return succeedWithPage(reportMateInventoryAgeFacade.queryReportMateInventoryAge(request));
    }

    @Operation(summary = "仓库库龄报表导出Excel")
    @GetMapping("/ReportMateInventoryAge/export")
    public CommonResponse<ExportInfo> exportReportMateInventoryAge(ReportMateInventoryAgeQueryRequest request) {
        return succeedWith(exportManager.exportReportMateInventoryAge(request));
    }
}